home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 January / Pcwk0198.iso / Dzieci / SIMPDATA / SIMPMAIN / 00012_animationRecordManager parent.ls < prev    next >
Encoding:
Text File  |  1996-09-01  |  9.6 KB  |  292 lines

  1. property ancestor
  2. global enterList, loopList, exitList, enterListCount, loopListCount, exitListCount, curDataChannel, theRecordingLayer, baseRecordSprOffset, autoHoldFrame, curClipRecord, clipDataField, overFlow, recordFlag, dirtyFlag, recordingDuplicateClip, scoreData, bgdData, fgdFXData, bgdFXData, currentFrame, frameLimit, theStageBounds, onionSkinSpr
  3.  
  4. on birth me
  5.   set the ancestor of me to birth(script "recordMethods parent")
  6.   return me
  7. end
  8.  
  9. on record me
  10.   set layerOverflow to 0
  11.   set theType to getAt(curClipRecord, 1)
  12.   set theGroup to getAt(curClipRecord, 2)
  13.   if isEmptyP(layerMgr) then
  14.     set curDataChannel to addNewSlot(layerMgr, theType, theGroup, clipDataField)
  15.   else
  16.     set curDataChannel to findDuplicateCategory(layerMgr, theGroup)
  17.     if curDataChannel = 0 then
  18.       set recordingDuplicateClip to 0
  19.       if isFullP(layerMgr) then
  20.         set layerOverflow to 1
  21.         set theMessage to "Sorry, you have used up all available channels."
  22.         set theAlertBoxType to #OK
  23.         showTheAlertBox(theMessage, theAlertBoxType, "nothing", "nothing", "nothing")
  24.       else
  25.         set curDataChannel to addNewSlot(layerMgr, theType, theGroup, clipDataField)
  26.         if (theType = "S") or (theType = "P") then
  27.           insertProp(layerMgr, theType, theGroup)
  28.         end if
  29.       end if
  30.     else
  31.       set recordingDuplicateClip to 1
  32.       showOnionSkin(me)
  33.     end if
  34.   end if
  35.   if not layerOverflow then
  36.     set theLayer to getLayer(layerMgr, theGroup)
  37.     set theRecordingLayer to theLayer + baseRecordSprOffset
  38.     buildFilterList(me)
  39.     setupClipData(me)
  40.     cursor(200)
  41.     set the locH of sprite theRecordingLayer to the mouseH
  42.     set the locV of sprite theRecordingLayer to the mouseV
  43.     update(stackMgr)
  44.     showFrame(playbackMgr, currentFrame, theRecordingLayer)
  45.     set enterListCount to count(enterList)
  46.     set loopListCount to count(loopList)
  47.     set exitListCount to count(exitList)
  48.     set cycleCount to 1
  49.     set cycleList to []
  50.     repeat with clipNumber in enterList
  51.       append(cycleList, clipNumber)
  52.     end repeat
  53.     repeat with clipNumber in loopList
  54.       append(cycleList, clipNumber)
  55.     end repeat
  56.     repeat with clipNumber in exitList
  57.       append(cycleList, clipNumber)
  58.     end repeat
  59.     repeat while the mouseUp
  60.       moveRecordingSpr(me, theRecordingLayer, the mouseH, the mouseV)
  61.       set cycleCount to cycleThruClips(me, cycleCount, cycleList)
  62.     end repeat
  63.     if cycleCount <= enterListCount then
  64.       set startList to #enterList
  65.     else
  66.       if cycleCount <= (enterListCount + loopListCount) then
  67.         set startList to #loopList
  68.         set cycleCount to cycleCount - enterListCount
  69.       else
  70.         set startList to #exitList
  71.         set cycleCount to cycleCount - (enterListCount + loopListCount)
  72.       end if
  73.     end if
  74.     beginRecording(me, the mouseH, the mouseV, startList, cycleCount)
  75.   end if
  76.   cursor(-1)
  77. end
  78.  
  79. on cycleThruClips me, cycleCount, cycleList
  80.   if the controlDown then
  81.     repeat while the controlDown
  82.     end repeat
  83.     if cycleCount < count(cycleList) then
  84.       set cycleCount to cycleCount + 1
  85.       set the castNum of sprite theRecordingLayer to getAt(cycleList, cycleCount)
  86.     else
  87.       set the castNum of sprite theRecordingLayer to getAt(cycleList, 1)
  88.       set cycleCount to 1
  89.     end if
  90.     updateStage()
  91.   end if
  92.   if the optionDown then
  93.     repeat while the optionDown
  94.     end repeat
  95.     if cycleCount > 1 then
  96.       set cycleCount to cycleCount - 1
  97.       set the castNum of sprite theRecordingLayer to getAt(cycleList, cycleCount)
  98.     else
  99.       set the castNum of sprite theRecordingLayer to getAt(cycleList, count(cycleList))
  100.       set cycleCount to count(cycleList)
  101.     end if
  102.     updateStage()
  103.   end if
  104.   return cycleCount
  105. end
  106.  
  107. on beginRecording me, theMouseH, theMouseV, startList, cycleCount
  108.   set theMouseLoc to point(theMouseH, theMouseV)
  109.   if inside(theMouseLoc, theStageBounds) or the shiftDown then
  110.     cursor(200)
  111.     set startFrame to currentFrame
  112.     set overFlow to 0
  113.     if startList = #enterList then
  114.       recordAnticipation(me, cycleCount, theMouseH, theMouseV)
  115.     else
  116.       if startList = #loopList then
  117.         recordExecution(me, cycleCount, theMouseH, theMouseV)
  118.       else
  119.         recordFollowThru(me, cycleCount, theMouseH, theMouseV)
  120.       end if
  121.     end if
  122.     if overFlow then
  123.       showOverFlowDialog(me)
  124.     end if
  125.     cursor(4)
  126.     extendClips(me)
  127.     if currentFrame > 1 then
  128.       decrementFrame()
  129.     end if
  130.     incrementCounter(playbackMgr)
  131.     if recordingDuplicateClip then
  132.       hideOnionSkin(me)
  133.     end if
  134.     showFrame(playbackMgr, currentFrame, 0)
  135.     set dirtyFlag to 1
  136.     updateTheBrain(appMgr)
  137.     cursor(-1)
  138.   else
  139.     cursor(4)
  140.     deleteLastSlot(layerMgr, getAt(curClipRecord, 2))
  141.     update(stackMgr)
  142.     hideRecordingSpr(me, theRecordingLayer)
  143.     if recordingDuplicateClip then
  144.       hideOnionSkin(me)
  145.     end if
  146.     showFrame(playbackMgr, currentFrame, 0)
  147.     cursor(-1)
  148.   end if
  149. end
  150.  
  151. on recordAnticipation me, cycleCount, theClipH, theClipV
  152.   repeat with theClipNumber = cycleCount to enterListCount
  153.     if currentFrame < frameLimit then
  154.       if recordingDuplicateClip then
  155.         showOnionSkin(me)
  156.       end if
  157.       if currentFrame > count(scoreData) then
  158.         setAt(scoreData, currentFrame, copyList(autoHoldFrame))
  159.       end if
  160.       set theClip to getAt(enterList, theClipNumber)
  161.       set the castNum of sprite theRecordingLayer to theClip
  162.       if the mouseDown then
  163.         set theClipH to the mouseH
  164.         set theClipV to the mouseV
  165.       end if
  166.       set the loc of sprite theRecordingLayer to point(theClipH, theClipV)
  167.       setAt(getAt(scoreData, currentFrame), curDataChannel, list(theClip, theClipH, theClipV))
  168.       incrementCounter(playbackMgr)
  169.       setKrustyForRecording(playbackMgr)
  170.       showFrame(playbackMgr, currentFrame, theRecordingLayer)
  171.       set currentFrame to currentFrame + 1
  172.       next repeat
  173.     end if
  174.     set overFlow to 1
  175.     exit repeat
  176.   end repeat
  177.   if not overFlow then
  178.     set cycleCount to 1
  179.     recordExecution(me, cycleCount, theClipH, theClipV)
  180.   end if
  181. end
  182.  
  183. on recordExecution me, cycleCount, theClipH, theClipV
  184.   repeat with theClipNumber = cycleCount to loopListCount
  185.     if currentFrame < frameLimit then
  186.       if recordingDuplicateClip then
  187.         showOnionSkin(me)
  188.       end if
  189.       if currentFrame > count(scoreData) then
  190.         setAt(scoreData, currentFrame, copyList(autoHoldFrame))
  191.       end if
  192.       set theClip to getAt(loopList, theClipNumber)
  193.       set the castNum of sprite theRecordingLayer to theClip
  194.       if the mouseDown then
  195.         set theClipH to the mouseH
  196.         set theClipV to the mouseV
  197.       end if
  198.       set the loc of sprite theRecordingLayer to point(theClipH, theClipV)
  199.       setAt(getAt(scoreData, currentFrame), curDataChannel, list(theClip, theClipH, theClipV))
  200.       incrementCounter(playbackMgr)
  201.       setKrustyForRecording(playbackMgr)
  202.       showFrame(playbackMgr, currentFrame, theRecordingLayer)
  203.       set currentFrame to currentFrame + 1
  204.       next repeat
  205.     end if
  206.     set overFlow to 1
  207.     exit repeat
  208.   end repeat
  209.   if not overFlow then
  210.     recordLoopingExecution(me, cycleCount, theClipH, theClipV)
  211.   end if
  212. end
  213.  
  214. on recordLoopingExecution me, cycleCount, theClipH, theClipV
  215.   repeat while the mouseDown
  216.     repeat with theClip in loopList
  217.       if currentFrame < frameLimit then
  218.         if recordingDuplicateClip then
  219.           showOnionSkin(me)
  220.         end if
  221.         if currentFrame > count(scoreData) then
  222.           setAt(scoreData, currentFrame, copyList(autoHoldFrame))
  223.         end if
  224.         set the castNum of sprite theRecordingLayer to theClip
  225.         if the mouseDown then
  226.           set theClipH to the mouseH
  227.           set theClipV to the mouseV
  228.         end if
  229.         set the loc of sprite theRecordingLayer to point(theClipH, theClipV)
  230.         setAt(getAt(scoreData, currentFrame), curDataChannel, list(theClip, theClipH, theClipV))
  231.         incrementCounter(playbackMgr)
  232.         setKrustyForRecording(playbackMgr)
  233.         showFrame(playbackMgr, currentFrame, theRecordingLayer)
  234.         set currentFrame to currentFrame + 1
  235.         next repeat
  236.       end if
  237.       set overFlow to 1
  238.       exit repeat
  239.     end repeat
  240.   end repeat
  241.   if not overFlow then
  242.     set cycleCount to 1
  243.     recordFollowThru(me, cycleCount, theClipH, theClipV)
  244.   end if
  245. end
  246.  
  247. on recordFollowThru me, cycleCount, theClipH, theClipV
  248.   repeat with theClipNumber = cycleCount to exitListCount
  249.     if currentFrame < frameLimit then
  250.       if recordingDuplicateClip then
  251.         showOnionSkin(me)
  252.       end if
  253.       if currentFrame > count(scoreData) then
  254.         setAt(scoreData, currentFrame, copyList(autoHoldFrame))
  255.       end if
  256.       set theClip to getAt(exitList, theClipNumber)
  257.       set the castNum of sprite theRecordingLayer to theClip
  258.       if the mouseDown then
  259.         set theClipH to the mouseH
  260.         set theClipV to the mouseV
  261.       end if
  262.       set the loc of sprite theRecordingLayer to point(theClipH, theClipV)
  263.       setAt(getAt(scoreData, currentFrame), curDataChannel, list(theClip, theClipH, theClipV))
  264.       incrementCounter(playbackMgr)
  265.       setKrustyForRecording(playbackMgr)
  266.       showFrame(playbackMgr, currentFrame, theRecordingLayer)
  267.       set currentFrame to currentFrame + 1
  268.       next repeat
  269.     end if
  270.     set overFlow to 1
  271.     exit repeat
  272.   end repeat
  273. end
  274.  
  275. on showOnionSkin me
  276.   if currentFrame <= count(scoreData) then
  277.     set onionClip to getAt(getAt(scoreData, currentFrame), curDataChannel)
  278.     if onionClip <> EMPTY then
  279.       set the castNum of sprite onionSkinSpr to getAt(onionClip, 1)
  280.       set the loc of sprite onionSkinSpr to point(getAt(onionClip, 2), getAt(onionClip, 3))
  281.     else
  282.       hideOnionSkin(me)
  283.     end if
  284.   else
  285.     hideOnionSkin(me)
  286.   end if
  287. end
  288.  
  289. on hideOnionSkin me
  290.   set the locH of sprite onionSkinSpr to -1000
  291. end
  292.